import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
   Encrypts a file using the Caesar cipher.
 */
public class Scramble
{ 
	public static void main(String[] args)
	{  
		JavaHowTo.Instance.cls();
		System.out.println("Provide a scramble key for SCADA (type 'quit' to exit):");
		InputStreamReader converter = new InputStreamReader(System.in);
		BufferedReader inbuf = new BufferedReader(converter);
		String CurLine;
		try {
			CurLine = inbuf.readLine();

		if (!(CurLine.equals("quit"))){
			try
			{  
				FileInputStream in = new FileInputStream("StartUp.class");
				FileOutputStream out = new FileOutputStream("StartUp.encrypted");
				int newkey = 0;
				for(char b: CurLine.toCharArray())
				{
					newkey += (int)b; 
				}
				int ch;
				while ((ch = in.read()) != -1)
				{  
					byte c = (byte)(ch + newkey);
					out.write(c);
				}
				in.close();
				out.close();
			}
			catch(IOException exception)
			{  
				exception.printStackTrace();
			}
		}
	
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}
	}